<?php
/**
 * Created by PhpStorm.
 * User: lengbin
 * Date: 2018/8/1
 * Time: 下午4:36
 */

namespace common\helpers;

class DictHelper
{

    /**
     * 获得 角色
     *
     * @param bool $isJson
     *
     * @return array
     */
    public static function getRole($isJson = true)
    {
        $params = [
            ConstantHelper::USER_ROLE_STUDENT => '学生',
            ConstantHelper::USER_ROLE_PARENT  => '家长',
            ConstantHelper::USER_ROLE_TEACHER => '老师',
        ];
        return $isJson ? BaseHelper::formattingDataForJson($params) : $params;
    }



    /**
     * 获得 是否有效
     *
     * @param bool $isJson
     *
     * @return array
     */
    public static function getIsStop($isJson = true)
    {
        $params = [
            ConstantHelper::NOT_DELETE => '有效',
            1                          => '冻结',

        ];
        return $isJson ? BaseHelper::formattingDataForJson($params) : $params;
    }

    /**
     * 获得 是否 选项
     *
     * @param bool $isJson
     *
     * @return array
     */
    public static function getYesOrNo($isJson = true)
    {
        $params = [
            ConstantHelper::NOT_DELETE => '是',
            1                          => '否',

        ];
        return $isJson ? BaseHelper::formattingDataForJson($params) : $params;
    }

    /**
     * 获得 性别 类型
     *
     * @param bool $isJson
     *
     * @return array
     * @author lengbin(lengbin0@gmail.com)
     */
    public static function getGenderType($isJson = true)
    {
        $params = [
            ConstantHelper::USER_GENDER_MAN   => '男',
            ConstantHelper::USER_GENDER_WOMAN => '女',
            ConstantHelper::USER_GENDER_UNDEFINED => '未知',
        ];
        return $isJson ? BaseHelper::formattingDataForJson($params) : $params;
    }

    /**
     * 获得 星期
     *
     * @param bool $isJson
     *
     * @return array
     */
    public static function getWeek($isJson = true)
    {
        $params = [
            ConstantHelper::WEEK_MONDAY    => '星期一',
            ConstantHelper::WEEK_TUESDAY   => '星期二',
            ConstantHelper::WEEK_WEDNESDAY => '星期三',
            ConstantHelper::WEEK_THURSDAY  => '星期四',
            ConstantHelper::WEEK_FRIDAY    => '星期五',
            ConstantHelper::WEEK_SATURDAY  => '星期六',
            ConstantHelper::WEEK_SUNDAY    => '星期天',
        ];
        return $isJson ? BaseHelper::formattingDataForJson($params) : $params;
    }




    /**
     *  获取2个时间之间的月份
     */
    public static  function getBetweenMonth($start_time,$end_time){
        $month = [];
        $start    = new \DateTime(date('Y-m-d',$start_time));
        $end      = new \DateTime(date('Y-m-d',$end_time));
// 时间间距 这里设置的是一个月
        $interval = \DateInterval::createFromDateString('1 month');
        $period   = new \DatePeriod($start, $interval, $end);
        foreach ($period as $dt) {
            $month[] = $dt->format("Ym");
        }
        return $month;
    }





}
